<?php

/**
 * 
 * @project     : innoTweets 1.0
 * @author      : Dino (DBK)
 * 
 * @package     : Ignore Model
 * @description : Database functions related to ignoring (Report Abuse)
 * 
 */
class Ignore_model extends CI_Model {

  function __construct() {
    parent::__construct();
  }

  // Insert a new ignore
  function add_ignore($ignore_type = NULL, $ignore_type_id = NULL, $user_id = NULL) {
    $result_data = array();
    $result_data['status'] = 0;
    $result_data['result'] = '';
    $result_data['count'] = 0;
    if (!empty($ignore_type) && !empty($ignore_type_id) && is_numeric($ignore_type_id) && !empty($user_id) && is_numeric($user_id)) {
      $query_insr = array(
          'ignore_type' => $ignore_type,
          'ignore_type_id' => $ignore_type_id,
          'ignore_user_id' => $user_id
      );
      $query_sql = $this->db->insert_string('ignores', $query_insr);
      $query_sql = str_replace('INSERT INTO', 'INSERT IGNORE INTO', $query_sql);
      $query_exec = $this->db->query($query_sql);
      if ($query_exec == TRUE) {
        $result_data = array();
        $result_data['status'] = $this->db->affected_rows();
        $result_data['result'] = $this->db->affected_rows();
        $result_data['count'] = 1;
      }
    }
    return $result_data;
  }

  // Get ignores
  function get_ignore($ignore_type = NULL, $ignore_type_id = NULL) {
    $result_data = array();
    $result_data['status'] = 0;
    $result_data['result'] = '';
    $result_data['count'] = 0;
    if (!empty($ignore_type) && !empty($ignore_type_id) && is_numeric($ignore_type_id)) {
      $query_cond = array();
      $query_cond['ignore_type'] = $ignore_type;
      $query_cond['ignore_type_id'] = $ignore_type_id;
      $query_exec = $this->db->get_where('ignores', $query_cond);
      if ($query_exec == TRUE) {
        $result_data = array();
        $result_data['status'] = 1;
        $result_data['result'] = $query_exec->result_array();
        $result_data['count'] = $query_exec->num_rows();
      }
    }
    return $result_data;
  }

}

?>